<template>
  <div>
    <el-form label-position="right" label-width="80px" size="small">
      <el-form-item label="柱条背景色是否显示">
        <el-switch v-model="series.showBackground"
                   @change="(val)=>{return this.handleChange(val,'series.bar.showBackground')}"></el-switch>
      </el-form-item>
      <el-form-item label="柱条背景色">
        <el-color-picker v-model="series.backgroundStyle.color"
                         @change="(val)=>{return this.handleChange(val,'series.bar.backgroundStyle.color')}"></el-color-picker>
      </el-form-item>
      <el-form-item label="是否显示标签">
        <el-switch v-model="series.label.show"
                   @change="(val)=>{return this.handleChange(val,'series.bar.label.show')}"></el-switch>
      </el-form-item>
      <el-form-item label="标签颜色">
        <el-color-picker v-model="series.label.color"
                         @change="(val)=>{return this.handleChange(val,'series.bar.label.color')}"></el-color-picker>
      </el-form-item>
      <el-form-item label="标签位置">
        <el-select v-model="series.label.position"
                   @change="(val)=>{return this.handleChange(val,'series.bar.label.position')}">
          <el-option v-for="(item,index) in labelPosition" :value="item" :label="item" :key="index"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="柱状颜色">
        <color-picker v-model="series.itemStyle.color"
                      @change="(val)=>{return this.handleChange(val,'series.bar.itemStyle.color')}"
        ></color-picker>
      </el-form-item>
      <el-form-item label="柱状圆角半径">
        <el-input-number v-model="series.itemStyle.borderRadius" :min="0" :max="10"
                         @change="(val)=>{return this.handleChange(val,'series.bar.itemStyle.borderRadius')}"></el-input-number>
      </el-form-item>
      <el-form-item label="柱状宽度">
        <el-input v-model="series.barWidth" :min="0" :max="10"
                         @change="(val)=>{return this.handleChange(val,'series.bar.barWidth')}"></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {mapMutations} from 'vuex'
import ColorPicker from "../../../common/ColorPicker";

export default {
  name: "Index",
  components: {ColorPicker},
  data() {
    return {
      labelPosition: [
        "top", "left", "right", "bottom", "inside", "insideLeft", "insideRight", "insideTop", "insideBottom", "insideTopLeft", "insideBottomLeft", "insideTopRight", "insideBottomRight"
      ]
    }
  },
  computed: {
    series() {
      return this.$store.getters.getOption('series.bar');
    }
  },
  methods: {
    ...mapMutations([
      'setOption',
    ]),
    handleChange(value, path) {
      return this.setOption({path, option: value})
    }
  }

}
</script>

<style scoped>

</style>